The present invention relates to digital computers, and, more particularly, to a software technique for verifying that execution of an instruction will not produce an unrecoverable processor error.
Processors function by executing instructions. Sometimes an instruction cannot be carried out for any of a variety of possible reasons and generates an exception. For example, a memory page at which an instruction resides may not be in main memory and must be paged in before the instruction can execute, or an instruction might not have permission to store to a specific address. When such an exception occurs, further processing of the instruction is temporarily halted, until the exception is resolved. Resolution is accomplished with an exception handler, a software routine specifically designed to deal with such exceptions. A processor typically contains different exception handlers to handle each kind of exception that might occur. Typically those software routines handle and resolve the exception before further processing of program instructions is permitted to continue.
Whenever a host instruction is to be executed, numerous checks (herein referred to as xe2x80x9cpreliminary checksxe2x80x9d) are routinely made at execution units of the processor to determine whether the instruction will be executed or, alternately, cause an exception. As an example, a store operation is performed by a write of data to an address in the memory (the hardware unit) of the processor. Before allowing the write to proceed, the memory checks for write permissions and for page present.
Other checks of that instruction (herein referred to as xe2x80x9cfinal checksxe2x80x9d), not material to the invention, are also made by the hardware unit to which the operation performed is directed after the result of the operation has been committed. That check (or checks) could also result in an exception. As example during the write of data by the processor into the memory unit, an electronic xe2x80x9cglitchxe2x80x9d, though rare, may occur and corrupt the data being written. The memory unit detects the corruption of data and signals the processor of the damaged data. However since the write operation was committed, the written data remains corrupted, creating an error. The invention does not offer a solution to that kind of problem.
If the instruction passes the preliminary checks, the operation specified in the instruction is completed. If any fail, an exception occurs. The processor is then required to resolve the exception before the operation specified in the instruction, the final effect, the write to memory in the preceding example, can be performed.
The foregoing is understood to apply to processors in general and to those processors that process very long instruction word (VLIW) instructions. One example of a VLIW processor disclosed in the patent literature is found in U.S. Pat. No. 5,832,205 to Kelly et al, granted Nov. 3, 1998, entitled, Memory Controller For A Microprocessor For Detecting A Failure of Speculation On The Physical Nature of A Component Being Addressed, assigned to Transmeta Corporation (referred to as the ""205 Transmeta patent), the disclosure of which is incorporated herein by reference. Another appears the improved VLIW processor system of Torvalds and Keppel based on the foregoing invention of the ""205 Transmeta patent presented in a copending application Ser. No. 09/417358, filed Oct. 13, 1999, entitled Controlling Instruction Translation Using Dynamic Feedback, (herein referred to as the xe2x80x9cimproved Transmeta computerxe2x80x9d), assigned to Transmeta Corporation, the disclosure of which is incorporated herein by reference. As later herein described in greater detail, the present invention has particular application to and improves the operation of the foregoing computers. However, although the present invention has application to the improved Transmeta computer, it should be understood that the invention may also be found to benefit other types of computers as well.
The microprocessor of the ""205 Transmeta patent is formed by a combination of a hardware processing portion (called a xe2x80x9cmorph hostxe2x80x9d), and an emulating software portion, referred to therein as xe2x80x9ccode morphing softwarexe2x80x9d. Among other things, the code morphing software carries out a significant portion of the functions of processors in software, reducing the hardware required for processing and the greater electrical power that such hardware requires. The ""205 Transmeta computer serves as the host system capable of executing software programs designed with an instruction set intended to run on a computer system of different design, the target system, one, such as the X86 type processor, that contains an instruction set unique to the target system, but foreign to the host system.
The present invention addresses the preliminary checks and the exceptions that may result therefrom (the latter herein referred to as a preliminary exception), not the final checks or any exceptions that result from the latter (herein called a final exception, to distinguish from the former exception). Thus, as used herein in connection with the invention, the term preliminary exception refers to a particular kind of out-of-ordinary event that occurs before the operation defined in the instruction is committed; and differs from the other exceptions as may result from the hardware check by that hardware unit of the processor upon actually performing the operation.
Any operation may require preliminary checks. Those checks must execute and generate any needed exceptions before the results of the operation are committed to the machine state. In many prior processors the preliminary checks are performed by the hardware and so are invisible to the software programmer. The hardware may perform the checks before the operation by the hardware, or, in a processor that employs out-of-order execution, may perform the checks concurrently with or even after the bulk of the operation, provided that, with the latter two techniques, the check completes before the operation result is committed.
In the processor of the improved Transmeta computer and in other processors that support speculation, software-managed hardware controls the committing of most machine state. Therefore, with processors of the foregoing type, it is sufficient to speculatively execute the desired operation, provided that the check is executed before the final commit of the result to the machine state.
Some operations, however, may not be speculated. For example, a read of an external device may cause the state of the device to change. The processor of the improved Transmeta computer is unable to roll-back or undo such a read operation. Hence, in the case of the read of an external device, the preliminary check must always precede the read operation. Any failure to perform the preliminary check could potentially result in an unrecoverable error.
In addition, it may sometimes be advantageous to perform the preliminary check as early as possible, so that an exception, as may be generated thereby, may be handled immediately, instead of executing speculated operations and then discarding the result upon occurrence of such exception.
One example of the manner in which preliminary checking is used is a read-modify-write operation, an operation used to increment a register of a peripheral device, external to the processor. Typically, load operations contain implied tests, such as xe2x80x9cReadablexe2x80x9d, and write operations have tests, such as xe2x80x9cWriteablexe2x80x9d. For the read-modify-write to execute correctly, either both the read and the write must occur, or neither should occur. It is an unrecoverable error if only the read occurs. However, an ordinary xe2x80x9cload, increment and storexe2x80x9d sequence may successfully execute the load, and then fail on the store, as could occur, as an example, if the location is readable, but is not writeable.
As an advantage, the present invention is available for use by the software engineer when a program is being authored, and allows the software engineer to integrate checks within that program. The checks are positioned only at those locations within the program at which the software engineer""s judgment dictates, as minimizes impacting processor time unnecessarily.
Accordingly, an object of the present invention is to improve the flexibility and power of a computer, and, particularly, a VLIW computer.
Another object of the invention is to avoid execution of an operation occurring on execution of an instruction by the processor if the operation would produce an unrecoverable error.
A further object of the invention is to avoid the performance of one or more operations specified in an instruction when the performance of one of the operations will produce an error if another of the multiple operations specified in the instruction cannot be successfully completed.
A still further object of the invention is to provide one or more test instructions that serve as software tools enabling a software engineer to selectively incorporate test instructions within a software program being authored logically paired or connected to an instruction (or instructions) of the program which the software engineer believes to be potentially troublesome.
An additional object of the invention is to provide check instructions that mimic instructions of a program, but not the final effect or operation of the mimicked instruction, which enable potential exceptions as might cause an unrecoverable error to be recognized in advance and resolved.
And a still further object of the invention is to provide a better mechanism for minimizing or eliminating errors occurring during processing of instructions.
In accordance with the foregoing objects, the present invention provides a new instruction, referred to as a check instruction that the software engineer may introduce into a software program. The check instruction mimics an instruction in most important respects, except that the check instruction does not perform, at a minimum, the final operation prescribed in the mimicked instruction. By executing the check instruction, as an example, prior to the associated mimicked instruction, the processor is able to uncover in advance and, ideally, resolve any preliminary exceptions likely to arise upon the assertion of the instruction for execution, without actually performing the final operation called for in the mimicked instruction.
By design the check instruction may be fashioned to exclude not only the final operation, but also some preliminary checks, if, in the software engineer""s judgment, the exceptions as would have been detected by the eliminated attributes of the mimicked instruction are known to be of types that are handled by a separate means or are always resolved by the processor and cannot lead to an unrecoverable error.
In essence, the check instruction provides a xe2x80x9cdry runxe2x80x9d of the instruction, revealing potential problems. Those problems may then be corrected or otherwise handled by the processor in advance, ensuring that the actual instruction, presented for execution subsequently, either next or following one or more intervening operations, is able to complete.
The invention also encompasses a method of verifying that an instruction is capable of performing a final operation prescribed in the instruction without causing a particular type or types of preliminary exceptions by executing an instruction, the check instruction, that mimics the instruction in many or all respects, but excluding at least the final effect or operation called for by the instruction; and determining whether such execution is subject to a preliminary exception. The check instruction may also exclude certain checks (and, hence, any resultant exceptions) that, in the judgment of the software scientist, would not result in an unrecoverable error or for which other mechanisms, the details of which are neither relevant or material to the present invention, are available for successfully handling the particular kind of preliminary exceptions associated with the omitted checks.
Moreover, in accordance with an additional aspect to the method, a detected preliminary exception can be resolved, and, following such resolution, the mimicked instruction may be executed to perform the final operation (or be found subject to a final exception) or, alternatively, where the mimicked instruction is speculatively executed in parallel with a check instruction, detection of a preliminary exception by the check instruction is used to prevent the processor from committing the result of the speculative execution of the mimicked instruction.
The new instruction and method allows the software engineer to include appropriate check instructions for any instructions believed to be troublesome, placing the check instruction in the program routine, preferably in a position preceding any committed xe2x80x9cside effectsxe2x80x9d of the mimicked instruction. The mimicked instruction may be positioned in the software program immediately following the check instruction or following one or more instructions positioned intermediate the check instruction and the mimicked instruction.
The foregoing and additional objects and advantages of the invention together with the structure characteristic thereof, which was only briefly summarized in the foregoing passages, becomes more apparent to those skilled in the art upon reading the detailed description of a preferred embodiment, which follows in this specification, taken together with the illustration thereof presented in the accompanying drawings.